var t = require("../core"),
  i = {
    hire: [{
      id: "1",
      title: "元/时薪"
    }, {
      id: "2",
      title: "元/日薪"
    }],
    sell: [{
      id: "1",
      title: "元/台"
    }]
  };
Component((0, t.formItem)()({
  properties: {
    type: {
      type: String,
      value: ""
    },
    rangeList: {
      type: Array,
      value: []
    }
  },
  data: {
    visible: !1,
    value: "",
    title: "",
    list: []
  },
  observers: {
    value: function (t) {
      if (t) {
        var i, e = null === (i = this.data.list) || void 0 === i ? void 0 : i.find((function (i) {
          return i.id == t
        }));
        e && this.setData({
          title: e.title || ""
        })
      }
    }
  },
  lifetimes: {
    attached: function () {
      var t, e = this;
      null !== (t = this.data.rangeList) && void 0 !== t && t.length && this.setData({
        list: this.data.rangeList
      }), this.data.type && this.setData({
        list: i[this.data.type]
      }, (function () {
        var t;
        if (!e.data.value && null !== (t = e.data.list) && void 0 !== t && t.length) {
          var i = e.data.list[0];
          e.setData({
            title: i.title || ""
          }), e.onChange(i.id)
        }
      }))
    }
  },
  methods: {
    onSwitchPopup: function () {
      var t;
      1 != (null === (t = this.data.list) || void 0 === t ? void 0 : t.length) && this.setData({
        visible: !this.data.visible
      })
    },
    onUnitClick: function (t) {
      var i = t.target.dataset.item;
      this.setData({
        visible: !1,
        title: i.title || ""
      }), this.onChange(i.id)
    }
  }
}));